const app = getApp();
Component({
  properties: {
   
  },
  data: {
    
  },
  attached: function () {
    var that = this;
    that.requestSetting();
  },
  methods: {
    requestSetting: function () {
      var that = this;
      //发起请求，获取列表列表
      wx.showLoading({
        title: '加载中',
      })
      wx.request({
        url: app.globalData.requestUrl,
        data: {
          map: 'applet_index_cfg'
        },
        success: function (res) {
          console.log(res.data);
          if (res.data.ec == 200) {
            var dataInfo = res.data.data;
            that.setData({
              settingInfo: dataInfo
            })
          } else {
            app.errorTip(that, res.data.em, 2000);
          }
        },
        complete: function () {
          wx.hideLoading();
          wx.stopPullDownRefresh();
        }
      });
    },
    hideGetuser: function () {
      var that = this;
      that.setData({
        isShowgetuser: false
      })
    },
    initPage:function(){
      console.log("组件触发页面初始化");
      this.triggerEvent('initPage');
    },
    // 获取用户信息
    getuserInfo: function (e) {
      var that = this;
      console.log(e);
      console.log(e.detail);
      if (e.detail) {
        var userdata = e.detail;
        if (userdata.userInfo){
          console.log(userdata);
          var slient = that.data.slient;
          var again = false;
          if (slient == 0) {
            again = true;
          }
          app.getuserInfo(that, userdata, again);
        }else{
          app.errorTip(that, '授权失败，为了您的完整体验，需要您的授权。', 2000);
        }
      }
    },
  }
})